import time

from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
TIMEOUT=10
class Base():
    def __init__(self,driver):
        self.driver=driver
    def goto(self,url):
        self.driver.get(url)
    def wait_click(self,locator,timeout=None) -> WebElement:
        timeout=TIMEOUT if timeout is None else TIMEOUT
        wait=WebDriverWait(self.driver,timeout)
        return wait.until(EC.element_to_be_clickable(locator))
    def click(self,locator):
        el=self.wait_click(locator)
        el.click()
    def fill(self,locator,word):
        el=self.wait_click(locator)
        el.send_keys(word)
    def sleep_time(self,wait_time):
        time.sleep(wait_time)
    def gettext(self,locator):
        el=self.wait_click(locator)
        return el.text




